#include<iostream>
#include<stdlib.h>
#include<unistd.h>
using namespace std;


int main()
{
    pid_t id=fork();
    if(id<0)
    {
       cout<<"进程创建失败"<<endl;
    }
    else if(id==0)
    {
       while (1)
       {
          cout<<"我是子进程"<<"pid=="<<getpid()<<"   ppid=="<<getppid()<<endl;
          sleep(1);
       }
       
    }
    else
    {
      while(1)
      {
         cout<<"我是父进程"<<"pid=="<<getpid()<<"   ppid=="<< getppid()<<endl;
         sleep(1);
      }

    }
    return 0;
}
